<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i> 错误信息
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-input v-model="query.hospitalId" placeholder="医院ID" class="handle-input mr10" @keyup.enter.native="handleSearch"></el-input>
                <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
                <el-button type="el-button" icon="el-icon-delete" @click="handleReset">重置</el-button>
            </div>
            <el-table
                    :data="tableData"
                    border
                    class="table"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                    @selection-change="handleSelectionChange"
            >
                <el-table-column v-if="false" prop="id" label="ID" width="200" align="center" sortable></el-table-column>
                <el-table-column prop="robotNo" label="机器人编号" align="center"></el-table-column>
                <el-table-column prop="batchNo" label="批次编号" align="center" sortable></el-table-column>
                <el-table-column prop="productNo" label="出厂编号" align="center"></el-table-column>
                <el-table-column prop="productDate" label="出厂日期" align="center"></el-table-column>
                <el-table-column  prop="robotTypeText" label="机器人类型" align="center"></el-table-column>
                <el-table-column  prop="errorMessage" label="错误信息" align="center" width="300"></el-table-column>
                <el-table-column prop="hospitalId" label="医院ID" align="center" width="200"></el-table-column>
                <el-table-column prop="hospitalSystemId" label="系统编号" align="center"></el-table-column>
                <el-table-column  prop="createTime" label="创建时间" align="center" sortable></el-table-column>
<!--                <el-table-column  label="操作"  align="center">-->
<!--                    <template slot-scope="scope">-->
<!--                        <el-button-->
<!--                                type="text"-->
<!--                                icon="el-icon-view"-->
<!--                                @click="handleView(scope.$index, scope.row)"-->
<!--                        >查看</el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
            </el-table>
            <div class="pagination">
                <el-pagination
                        background
                        layout="total, prev, pager, next"
                        :current-page="query.pageIndex"
                        :page-size="query.pageSize"
                        :total="pageTotal"
                        @current-change="handlePageChange"
                ></el-pagination>
            </div>
        </div>

        <!-- 编辑弹出框 -->
        <el-dialog title="查看" :visible.sync="editVisible" width="50%" :close-on-click-modal="false">
            <el-form ref="form" :model="editForm" label-width="100px" >
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="系统编号:" prop="robotNo" >
                            <el-input disabled v-model="editForm.robotNo" style="width: 100%"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="设备批次:" prop="batchNo" >
                            <el-input disabled v-model="editForm.batchNo" style="width: 100%"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="出厂编号:" prop="productNo" >
                            <el-input disabled v-model="editForm.productNo" style="width: 100%"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="出厂日期:" prop="productDate" >
                            <el-input disabled v-model="editForm.productDate" style="width: 100%"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="医院ID:" prop="hospitalId" >
                            <el-input disabled v-model="editForm.hospitalId" style="width: 100%"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="系统编号:" prop="hospitalSystemId" >
                            <el-input disabled v-model="editForm.hospitalSystemId" style="width: 100%"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="上传时间:" prop="dataUpTime" >
                            <el-input disabled v-model="editForm.dataUpTime" style="width: 100%"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="错误信息:" prop="errorMessage" >
                            <el-input type="textarea" :rows="1" disabled v-model="editForm.errorMessage" style="width: 100%"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editVisible = false">关闭</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
    import { getData } from '../../../../api/sfrobot/sfrobotRobotError';
    export default {
        name: 'sfrobotRobotError',
        data() {
            return {
                query: {
                    hospitalId:'',
                    robotType:100041,
                    pageIndex: 1,
                    pageSize: 10
                },
                tableData: [],
                multipleSelection: [],
                editVisible: false,
                pageTotal: 0,
                editForm: {},
                idx: -1,
                id: -1,
            };
        },
        created() { //调用ajax获取页面初始化所需的数据
            this.getData();
        },
        methods: {
            // 获取后台数据
            getData() {
                getData(this.query).then(res => {
                    if (res.success == true){
                        this.tableData = res.data;
                        this.pageTotal = res.total;
                    } else {
                        this.$message.error("查询失败！");
                        this.tableData = [];
                        this.pageTotal = 0;
                    }
                });
            },
            // 触发搜索按钮
            handleSearch() {
                this.$set(this.query, 'pageIndex', 1);
                this.getData();
            },
            // 触发重置按钮
            handleReset() {
                this.query.hospitalId="";
                this.getData();
            },
            // 多选操作
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            // 分页导航
            handlePageChange(val) {
                this.$set(this.query, 'pageIndex', val);
                this.getData();
            },
            handleView(index, row){
                this.editForm = {};
                this.idx = index;
                this.editForm = row;
                this.editVisible = true;
            }
        }
    };
</script>

<style scoped>
    .handle-box {
        margin-bottom: 20px;
    }

    .handle-input {
        width: 300px;
        display: inline-block;
    }

    .table {
        width: 100%;
        font-size: 14px;
    }

    .mr10 {
        margin-right: 10px;
    }
</style>
